package com.xl.observer.special;

public class ConcreateWeatherSubject extends WeatherSubject {

    private String weather;

    public String getWeather() {
        return weather;
    }

    public void setWeather(String weather) {
        this.weather = weather;
        this.notifyObserver();
    }

    @Override
    protected void notifyObserver() {
        for(WeatherObserver wo : observers){

            if(weather.equals("晴天")){
                System.out.println("weather = " + this.weather + "  " + wo.getObserverName() + " Not to be notified");
            }else if(weather.equals("下雨")){
                if(wo.getObserverName().equals("gf") || wo.getObserverName().equals("mom")){
                    wo.update(this);
                }
            }else if(weather.equals("下雪")){
                if(wo.getObserverName().equals("mom")){
                    wo.update(this);
                }
            }
        }
    }


}
